#include "stdafx.h"
#include "CombatDataDef.h"
#include "InstanceTouch.h"
DECL_INSTANCE_TOUCH(ETouch_CombatDataDef);

struct  CombatDataDefDefReflectionRegister
{
	CombatDataDefDefReflectionRegister()
	{
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iID,INVALID_ID).Editor_SetAsPrimaryKey();
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_sDisplayName,std::string("DefaultName")).Editor_SetAsDisplayName();
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_sName,std::string("PlayerName")).Editor_SetAsRaw();
		
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iHeroDef,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_HeroCard);
		
		
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_bCustom,false).Editor_SetAsRaw("Custom");
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iHeroLvl,1).Editor_SetAsRaw("Custom");
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iHeroInnate0,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_InnateSkill,"Custom");
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iHeroInnate1,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_InnateSkill,"Custom");
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iHeroInnate2,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_InnateSkill,"Custom");
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iHeroInnate3,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_InnateSkill,"Custom");
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iHeroRage0,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_Reactors,"Custom");
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iHeroRage1,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_Reactors,"Custom");

		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iCard0,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_Card);
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iCard1,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_Card);
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iCard2,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_Card);
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iCard3,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_Card);
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iCard4,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_Card);
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iCard5,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_Card);
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iCard6,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_Card);
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iCard7,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_Card);
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iCard8,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_Card);
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_iCard9,INVALID_ID).Editor_SetAsForeignKey(eDefGroup_Default,eDefaultDef_Card);
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_fRageIncAddPercent,0.f).Editor_SetAsRaw("Modifier");
		REGISTER_REFLECTION_MEMBER(CombatDataDef,m_fRageIncAddValue,0.f).Editor_SetAsRaw("Modifier");

		GlobalClassManager::Instance().RegisterClass(CombatDataDef::s_GetReflection(),eDefaultDef_CombatDataDef);
		GlobalDefManager::Instance().RegisterDefManger(&CombatDataDefManager::Instance());

	}
}___CombatDataDefDefReflectionRegister;

rewrite  void CombatDataDef::OnArchieveReaded()
{
	m_vCards.clear();
	for(uint32 ii=0;ii<10;ii++)
	{
		std::stringstream ss;
		ss<<"m_iCard"<<ii;
		const CMember* pMember=GetReflection().LookupMember(ss.str());
		if(!pMember) continue;
		int32 iCardDef= * pMember->GetMemberData<int32>(this);
		if(iCardDef!=INVALID_ID)
		{
			m_vCards.push_back(iCardDef);
		}
	}
	m_vInnateSkills.clear();
	for(uint32 ii=0;ii<4;ii++)
	{
		std::stringstream ss;
		ss<<"m_iHeroInnate"<<ii;
		const CMember* pMember=GetReflection().LookupMember(ss.str());
		if(!pMember) continue;
		int32 iInnate= * pMember->GetMemberData<int32>(this);
		if(iInnate!=INVALID_ID)
		{
			m_vInnateSkills.push_back(iInnate);
		}
	}
}

void CombatDataDefManager::OnArchieveReaded()
{
	__CombatDataDefManager::OnArchieveReaded();
}